<template>
  <div class="announcement-detail-container">
    <el-card v-if="announcement">
      <template #header>
        <div class="header-content">
          <span>公告详情</span>
          <el-button @click="$router.back()">返回</el-button>
        </div>
      </template>

      <div class="announcement-content">
        <h2>{{ announcement.title }}</h2>
        <div class="meta">
          <span>发布时间：{{ formatDate(announcement.create_time) }}</span>
        </div>
        <div class="content">{{ announcement.content }}</div>
      </div>
    </el-card>
  </div>
</template>

<script setup>
import { ref, onMounted } from 'vue'
import { useRoute } from 'vue-router'
import { faker } from '@faker-js/faker'

const route = useRoute()

// 公告详情
const announcement = ref(null)

// 格式化日期
const formatDate = (date) => {
  return new Date(date).toLocaleString()
}

// 加载公告详情
const loadAnnouncement = () => {
  const announcementId = route.params.id

  // 生成模拟数据
  announcement.value = {
    announcement_id: announcementId,
    title: faker.lorem.sentence(),
    content: faker.lorem.paragraphs(5),
    create_time: faker.date.past()
  }
}

onMounted(() => {
  loadAnnouncement()
})
</script>

<style scoped>
.announcement-detail-container {
  padding: 20px;
  max-width: 800px;
  margin: 0 auto;
}

.header-content {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.announcement-content h2 {
  margin: 0 0 15px 0;
  color: #303133;
}

.meta {
  color: #909399;
  font-size: 14px;
  margin-bottom: 20px;
}

.content {
  color: #606266;
  line-height: 1.8;
}
</style> 